﻿using System;
using System.Numerics;
    class Tribonachi
    {
        static void Main()
        {
            BigInteger firstnumber=BigInteger.Parse(Console.ReadLine());
            BigInteger secondnumber=BigInteger.Parse(Console.ReadLine());
            BigInteger thirdnumber = BigInteger.Parse(Console.ReadLine());
                int N=int.Parse(Console.ReadLine());
                BigInteger[] finalnumber = new BigInteger[N]; ;
                finalnumber[0] = firstnumber;
                finalnumber[1] = secondnumber;
                finalnumber[2] = thirdnumber;
                for (int counter=3;counter<N;counter++  )
                {
                    finalnumber[counter] += finalnumber[counter - 1] + finalnumber[counter - 2] + finalnumber[counter - 3];
                }
                Console.WriteLine(finalnumber[N-1]);
        }
    }

